/**
 * Author: Lily Jiang
 * Create Time: 2019/9/3
 * Description:
 */

import React from "react";
import { connect } from "react-redux";
import * as actions from "../../store/actions";
import { Button } from 'antd-mobile';
import './Index.scss'

class SetUserInfo extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            message: 'a'
        };
    }

    handleUpdateUserInfo = () => {
        let dispatch = this.props.dispatch;
        dispatch(actions.updateAppSetting({
            user: {
                username: '蒋蒋蒋蒋',
                age: 18,
                sex: '女'
            },
            isLogin: true
        }));

        this.setState({
            message: 'b'
        });
    }

    checkApi = () => {
        React.$api.demo()
    }

    render() {
        return (
            <div>
                <div className="hahahha">{this.state.message}</div>
                <Button onClick={this.checkApi}>checkApi</Button>
                <button className="add-todo" onClick={this.handleUpdateUserInfo}>
                    update user info
                </button>
            </div>
        );
    }
}

export default connect()(SetUserInfo)